import Joi from '@hapi/joi';
import { paginateRule } from '../common';

export const indexRule = {
  query: {
    name: Joi.string().trim(),
    id: Joi.string().trim(),
    ...paginateRule,
  },
};

export const createRule = {
  body: {
    amount: Joi.number(),
    count: Joi.number(),
    min_point: Joi.number(),
    per_limit: Joi.number(),
    platform: Joi.number(),
    coupon_start_time: Joi.number(),
    coupon_end_time: Joi.number(),
    type: Joi.number(),
    use_type: Joi.number(),
    name: Joi.string().required(),
    note: Joi.string().required(),
  },
};

export const updateRule = {
  params: {
    id: Joi.string(),
  },
  body: createRule.body
};

export const destroyRule = {
  params: {
    id: Joi.string(),
  },
};

export const attrValRule = {
  params: {
    id: Joi.string()
  },
  body: {
    valList: Joi.array()
      .items(Joi.string())
      .required(),
  }
}